Passed
Pull Request — master (#121)
by
unknown
02:29
created

OAuthClient   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 9
eloc 29
dl 0
loc 31
rs 10
c 0
b 0
f 0

9 Functions

Rating   Name   Duplication   Size   Complexity  
A isRefreshTokenValid 0 1 1
A createToken 0 1 1
A refreshUsingToken 0 1 1
A revoke 0 1 1
A authorizeUri 0 1 1
A refresh 0 1 1
A getToken 0 1 1
A isAccessTokenValid 0 1 1
A setToken 0 1 1
1
declare module 'intuit-oauth' {
2
  export default OAuthClient;
3
4
  export type OAuthClientConfig = {
5
    clientId: string,
6
    clientSecret: string,
7
    environment: 'sandbox' | 'production',
8
    redirectUri: string,
9
    logging?: boolean
10
  };
11
12
  export class OAuthClient {
13
    public clientId: string;
14
    public clientSecret: string;
15
    public environment: string;
16
    public redirectUri: string;
17
    constructor(config: OAuthClientConfig);
18
    authorizeUri(params: AuthorizeUriParams): string;
19
    createToken(uri: string): Promise<Response<TokenData>>;
20
    refresh(): Promise<Response<TokenData>>;
21
    refreshUsingToken(refreshToken: string): Promise<Response<TokenData>>;
22
    revoke(params?: RevokeParams): Promise<Response>;
23
    isAccessTokenValid(): boolean;
24
    isRefreshTokenValid(): boolean;
25
    getToken(): Token;
26
    setToken(params?: TokenParams): Token;
27
    static scopes: {
28
      Accounting: string,
29
      Payment: string,
30
      Payroll: string,
31
      TimeTracking: string,
32
      Benefits: string,
33
      Profile: string,
34
      Email: string,
35
      Phone: string,
36
      Address: string,
37
      OpenId: string
38
    };
39
    static environment: {
40
      sandbox: string,
41
      production: string
42
    };
43
  };
44
45
  export class Response<T extends object = object> {
46
    getJson(): T;
47
  }
48
49
  export type TokenParams = {
50
    realmId?: string;
51
    token_type?: string;
52
    access_token?: string;
53
    refresh_token?: string;
54
    expires_in?: number;
55
    x_refresh_token_expires_in?: number;
56
    id_token?: string;
57
    latency?: number;
58
    createdAt?: Date;
59
  };
60
61
  export class Token {
62
    realmId: string;
63
    constructor(params?: TokenParams);
64
    accessToken(): string;
65
    refreshToken(): string;
66
    tokenType(): string;
67
    getToken(): TokenData;
68
    setToken(tokenData: TokenData): Token;
69
    clearToken(): Token;
70
    isAccessTokenValid(): boolean;
71
    isRefreshTokenValid(): boolean;
72
  };
73
74
  export type TokenData = {
75
    token_type: string;
76
    access_token: string;
77
    refresh_token: string;
78
    expires_in: number;
79
    x_refresh_token_expires_in: number;
80
    id_token: string;
81
    latency: number;
82
    createdAt: Date;
83
  };
84
85
  export type AuthorizeUriParams = {
86
    scope: string | Array<string>,
87
    state?: string
88
  };
89
90
  export type RevokeParams = {
91
    access_token?: string,
92
    refresh_token?: string
93
  };
94
}
95